package com.hbnu.system.controller;

import com.hbnu.system.core.base.Rest;
import com.hbnu.system.model.entity.DisciplineClassfi;
import com.hbnu.system.service.DisciplineClassfiService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/disciplineClassfi")
@Api(tags = "纵向-学科分类模块")
public class DisciplineClassfiController {
    @Autowired
    private DisciplineClassfiService disciplineClassfiService;

    @ApiOperation("学科分类添加")
    @PostMapping("/addDisciplineClassfi")
    public Rest<Boolean> addDisciplineClassfi(@RequestBody DisciplineClassfi disciplineClassfi){
        boolean add = disciplineClassfiService.addDisciplineClassfi(disciplineClassfi);
        return add ? Rest.success():Rest.failed();
    }

    @ApiOperation("获取学科分类列表")
    @GetMapping("/getDisciplineClassfi")
    public Rest<List<DisciplineClassfi>> getProjectcates(){
        List<DisciplineClassfi> projectcateList = disciplineClassfiService.getDisciplineClassfiList();
        return Rest.success(projectcateList);
    }

    @ApiOperation("学科分类-修改")
    @PostMapping("/updateDisciplineClassfi")
    public Rest<Boolean> updateDisciplineClassfi(@RequestBody DisciplineClassfi disciplineClassfi){
        boolean update = disciplineClassfiService.updateDisciplineClassfi(disciplineClassfi);
        return update ? Rest.success() : Rest.failed();
    }

    @ApiOperation("项目类别-删除")
    @GetMapping("/deleteDisciplineClassfi")
    public Rest<Boolean> deleteDisciplineClassfi(String DisciplineClassfiID){
        boolean delete = disciplineClassfiService.deleteDisciplineClassfi(DisciplineClassfiID);
        return delete ? Rest.success() : Rest.failed();
    }

   //根据学科名字进行查询
    @ApiOperation("根据学科名字进行查询")
    @GetMapping("/getDisciplineClassfiByName")
    public Rest<List<DisciplineClassfi>> getDisciplineClassfiByName(String DisciplineClassfiName){
        List<DisciplineClassfi> disciplineClassfi = disciplineClassfiService.getByDisplineClassfiName(DisciplineClassfiName);
        return Rest.success(disciplineClassfi);
    }

}
